package com.wedo.mall.activity.main;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.e.library.activity.EActivity;
import com.e.library.http.EApi;
import com.e.library.utils.EViewUtils;
import com.e.library.widget.ETitleBar;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.wedo.mall.R;
import com.wedo.mall.WApp;
import com.wedo.mall.activity.MapActivity;
import com.wedo.mall.adapter.AgentAdapter;
import com.wedo.mall.entity.Agent;
import com.wedo.mall.ptr.Pull2Refresh;

import butterknife.BindView;

/**
 * Created by lxy on 2017/6/28.
 */

public class NearbyActivity extends EActivity {

    @BindView(R.id.title_bar) ETitleBar title_bar;
    @BindView(R.id.tv_empty) TextView tv_empty;
    @BindView(R.id.rv_list) XRecyclerView rv_list;

    @Override
    protected int layout() {
        return R.layout.activity_nearby;
    }

    @Override
    protected void onActivityCreated(Bundle state) {
        rv_list.setHasFixedSize(true);
        EViewUtils.vertical(rv_list);
        final AgentAdapter adapter = AgentAdapter.search(this,null);
        adapter.listener(this);
        final Pull2Refresh<Agent> ptr = new Pull2Refresh<>();
        ptr.widget(rv_list).adapter(adapter).url(EApi.AGENT_NEARBY).params(WApp.lngLat()).clazz(Agent.class).emptyWidget(tv_empty).done();

        title_bar.setOnForwardListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MapActivity.toMap(NearbyActivity.this,ptr.datas());
            }
        });
    }

}
